package p270jp.pxv.android.view;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import p014ae.View$OnClickListenerC0151s;
import p014ae.View$OnClickListenerC0158t;
import p045be.NestedCommentAdapter;
import p062c4.ViewBindings;
import p064c6.Preconditions;
import p131ef.NestedCommentMapper;
import p156ff.NestedCommentItem;
import p189gn.AbstractC3435a;
import p210hh.PixivAccountManager;
import p216hn.Lambda;
import p216hn.Reflection;
import p270jp.pxv.android.R;
import p270jp.pxv.android.commonObjects.model.CommentAccessType;
import p270jp.pxv.android.commonObjects.model.PixivComment;
import p270jp.pxv.android.legacy.model.PixivWork;
import p274k2.ContextCompat;
import p314lg.WorkCaptionCommentItemBinding;
import p325m0.MutabilityOwnership;
import p376no.Koin;
import p404oo.AbstractC5475a;
import p579vo.Qualifier;
import p603wm.AbstractC6949c;
import p677zi.PixivImageLoader;

/* compiled from: DetailCommentsView.kt */
/* renamed from: jp.pxv.android.view.DetailCommentsView */
/* loaded from: classes2.dex */
public final class DetailCommentsView extends RelativeLayout implements AbstractC5475a {

    /* renamed from: e */
    public static final /* synthetic */ int f19483e;

    /* renamed from: a */
    public NestedCommentAdapter f19484a;

    /* renamed from: b */
    public WorkCaptionCommentItemBinding f19485b;

    /* renamed from: c */
    public final AbstractC6949c f19486c = Preconditions.m9802P(1, new C4369a(this, null, null));

    /* renamed from: d */
    public final AbstractC6949c f19487d = Preconditions.m9802P(1, new C4370b(this, null, null));

    /* compiled from: KoinComponent.kt */
    /* renamed from: jp.pxv.android.view.DetailCommentsView$a */
    /* loaded from: classes2.dex */
    public static final class C4369a extends Lambda implements AbstractC3435a<NestedCommentMapper> {

        /* renamed from: a */
        public final /* synthetic */ AbstractC5475a f19488a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4369a(AbstractC5475a aVar, Qualifier aVar2, AbstractC3435a aVar3) {
            super(0);
            this.f19488a = aVar;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [java.lang.Object, ef.a] */
        @Override // p189gn.AbstractC3435a
        public final NestedCommentMapper invoke() {
            return this.f19488a.getKoin().f24118a.m920a().m621a(Reflection.m5499a(NestedCommentMapper.class), null, null);
        }
    }

    /* compiled from: KoinComponent.kt */
    /* renamed from: jp.pxv.android.view.DetailCommentsView$b */
    /* loaded from: classes2.dex */
    public static final class C4370b extends Lambda implements AbstractC3435a<PixivImageLoader> {

        /* renamed from: a */
        public final /* synthetic */ AbstractC5475a f19489a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4370b(AbstractC5475a aVar, Qualifier aVar2, AbstractC3435a aVar3) {
            super(0);
            this.f19489a = aVar;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [java.lang.Object, zi.a] */
        @Override // p189gn.AbstractC3435a
        public final PixivImageLoader invoke() {
            return this.f19489a.getKoin().f24118a.m920a().m621a(Reflection.m5499a(PixivImageLoader.class), null, null);
        }
    }

    public DetailCommentsView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        View inflate = LayoutInflater.from(getContext()).inflate(R.layout.work_caption_comment_item, (ViewGroup) this, false);
        addView(inflate);
        int i = R.id.comment_input_view;
        LinearLayout linearLayout = (LinearLayout) ViewBindings.m9835b(inflate, R.id.comment_input_view);
        if (linearLayout != null) {
            i = R.id.comment_progress_bar;
            ProgressBar progressBar = (ProgressBar) ViewBindings.m9835b(inflate, R.id.comment_progress_bar);
            if (progressBar != null) {
                i = R.id.comment_state_text_view;
                TextView textView = (TextView) ViewBindings.m9835b(inflate, R.id.comment_state_text_view);
                if (textView != null) {
                    i = R.id.comments_list;
                    RelativeLayout relativeLayout = (RelativeLayout) ViewBindings.m9835b(inflate, R.id.comments_list);
                    if (relativeLayout != null) {
                        i = R.id.comments_recycler_view;
                        RecyclerView recyclerView = (RecyclerView) ViewBindings.m9835b(inflate, R.id.comments_recycler_view);
                        if (recyclerView != null) {
                            i = R.id.open_comment_input_bar;
                            TextView textView2 = (TextView) ViewBindings.m9835b(inflate, R.id.open_comment_input_bar);
                            if (textView2 != null) {
                                i = R.id.profile_image_view;
                                ImageView imageView = (ImageView) ViewBindings.m9835b(inflate, R.id.profile_image_view);
                                if (imageView != null) {
                                    i = R.id.read_more_text_view;
                                    LinearLayout linearLayout2 = (LinearLayout) ViewBindings.m9835b(inflate, R.id.read_more_text_view);
                                    if (linearLayout2 != null) {
                                        i = R.id.see_more_border;
                                        View b = ViewBindings.m9835b(inflate, R.id.see_more_border);
                                        if (b != null) {
                                            this.f19485b = new WorkCaptionCommentItemBinding((LinearLayout) inflate, linearLayout, progressBar, textView, relativeLayout, recyclerView, textView2, imageView, linearLayout2, b);
                                            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
                                            WorkCaptionCommentItemBinding mcVar = this.f19485b;
                                            if (mcVar != null) {
                                                mcVar.f21962f.setLayoutManager(linearLayoutManager);
                                                DividerItemDecoration oVar = new DividerItemDecoration(getContext(), linearLayoutManager.f3468p);
                                                Context context2 = getContext();
                                                Object obj = ContextCompat.f19963a;
                                                Drawable b2 = ContextCompat.C4472c.m4259b(context2, R.drawable.divider_work_comment);
                                                MutabilityOwnership.m3747j(b2);
                                                oVar.f3871a = b2;
                                                WorkCaptionCommentItemBinding mcVar2 = this.f19485b;
                                                if (mcVar2 != null) {
                                                    mcVar2.f21962f.m10871g(oVar);
                                                    WorkCaptionCommentItemBinding mcVar3 = this.f19485b;
                                                    if (mcVar3 != null) {
                                                        mcVar3.f21962f.setNestedScrollingEnabled(false);
                                                        NestedCommentAdapter v0Var = new NestedCommentAdapter();
                                                        this.f19484a = v0Var;
                                                        v0Var.f4932f = true;
                                                        WorkCaptionCommentItemBinding mcVar4 = this.f19485b;
                                                        if (mcVar4 != null) {
                                                            mcVar4.f21962f.setAdapter(v0Var);
                                                            return;
                                                        } else {
                                                            MutabilityOwnership.m3737u("binding");
                                                            throw null;
                                                        }
                                                    } else {
                                                        MutabilityOwnership.m3737u("binding");
                                                        throw null;
                                                    }
                                                } else {
                                                    MutabilityOwnership.m3737u("binding");
                                                    throw null;
                                                }
                                            } else {
                                                MutabilityOwnership.m3737u("binding");
                                                throw null;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i)));
    }

    private final NestedCommentMapper getNestedCommentMapper() {
        return (NestedCommentMapper) this.f19486c.getValue();
    }

    private final PixivImageLoader getPixivImageLoader() {
        return (PixivImageLoader) this.f19487d.getValue();
    }

    /* renamed from: a */
    public final void m4502a(PixivWork pixivWork, List<PixivComment> list, CommentAccessType commentAccessType) {
        MutabilityOwnership.m3745m(pixivWork, "work");
        MutabilityOwnership.m3745m(list, "comments");
        MutabilityOwnership.m3745m(commentAccessType, "commentAccessType");
        if (commentAccessType == CommentAccessType.DENY) {
            WorkCaptionCommentItemBinding mcVar = this.f19485b;
            if (mcVar != null) {
                mcVar.f21958b.setVisibility(8);
                WorkCaptionCommentItemBinding mcVar2 = this.f19485b;
                if (mcVar2 != null) {
                    mcVar2.f21961e.setVisibility(8);
                    WorkCaptionCommentItemBinding mcVar3 = this.f19485b;
                    if (mcVar3 != null) {
                        mcVar3.f21965i.setVisibility(8);
                        WorkCaptionCommentItemBinding mcVar4 = this.f19485b;
                        if (mcVar4 != null) {
                            mcVar4.f21960d.setText(getContext().getString(R.string.deny_comment));
                            WorkCaptionCommentItemBinding mcVar5 = this.f19485b;
                            if (mcVar5 != null) {
                                mcVar5.f21960d.setVisibility(0);
                            } else {
                                MutabilityOwnership.m3737u("binding");
                                throw null;
                            }
                        } else {
                            MutabilityOwnership.m3737u("binding");
                            throw null;
                        }
                    } else {
                        MutabilityOwnership.m3737u("binding");
                        throw null;
                    }
                } else {
                    MutabilityOwnership.m3737u("binding");
                    throw null;
                }
            } else {
                MutabilityOwnership.m3737u("binding");
                throw null;
            }
        } else {
            WorkCaptionCommentItemBinding mcVar6 = this.f19485b;
            if (mcVar6 != null) {
                mcVar6.f21958b.setVisibility(0);
                WorkCaptionCommentItemBinding mcVar7 = this.f19485b;
                if (mcVar7 != null) {
                    mcVar7.f21959c.setVisibility(8);
                    if (list.isEmpty()) {
                        WorkCaptionCommentItemBinding mcVar8 = this.f19485b;
                        if (mcVar8 != null) {
                            mcVar8.f21960d.setText(getContext().getString(R.string.no_comment));
                            WorkCaptionCommentItemBinding mcVar9 = this.f19485b;
                            if (mcVar9 != null) {
                                mcVar9.f21960d.setVisibility(0);
                            } else {
                                MutabilityOwnership.m3737u("binding");
                                throw null;
                            }
                        } else {
                            MutabilityOwnership.m3737u("binding");
                            throw null;
                        }
                    } else {
                        WorkCaptionCommentItemBinding mcVar10 = this.f19485b;
                        if (mcVar10 != null) {
                            mcVar10.f21960d.setVisibility(8);
                        } else {
                            MutabilityOwnership.m3737u("binding");
                            throw null;
                        }
                    }
                    NestedCommentAdapter v0Var = this.f19484a;
                    if (v0Var != null) {
                        v0Var.f4931e = pixivWork;
                        if (v0Var != null) {
                            v0Var.m10332r();
                            if (4 <= list.size()) {
                                list = list.subList(0, 3);
                                WorkCaptionCommentItemBinding mcVar11 = this.f19485b;
                                if (mcVar11 != null) {
                                    mcVar11.f21965i.setVisibility(0);
                                    WorkCaptionCommentItemBinding mcVar12 = this.f19485b;
                                    if (mcVar12 != null) {
                                        mcVar12.f21966j.setVisibility(0);
                                    } else {
                                        MutabilityOwnership.m3737u("binding");
                                        throw null;
                                    }
                                } else {
                                    MutabilityOwnership.m3737u("binding");
                                    throw null;
                                }
                            } else {
                                WorkCaptionCommentItemBinding mcVar13 = this.f19485b;
                                if (mcVar13 != null) {
                                    mcVar13.f21965i.setVisibility(8);
                                    WorkCaptionCommentItemBinding mcVar14 = this.f19485b;
                                    if (mcVar14 != null) {
                                        mcVar14.f21966j.setVisibility(8);
                                    } else {
                                        MutabilityOwnership.m3737u("binding");
                                        throw null;
                                    }
                                } else {
                                    MutabilityOwnership.m3737u("binding");
                                    throw null;
                                }
                            }
                            List<NestedCommentItem> a = getNestedCommentMapper().m6533a(list);
                            NestedCommentAdapter v0Var2 = this.f19484a;
                            if (v0Var2 != null) {
                                v0Var2.f4930d.addAll(a);
                                v0Var2.f3606a.m10780b();
                                WorkCaptionCommentItemBinding mcVar15 = this.f19485b;
                                if (mcVar15 != null) {
                                    mcVar15.f21965i.setOnClickListener(new View$OnClickListenerC0158t(pixivWork, 25));
                                    PixivImageLoader pixivImageLoader = getPixivImageLoader();
                                    Context context = getContext();
                                    MutabilityOwnership.m3746l(context, "context");
                                    String str = PixivAccountManager.m5511e().f16502h;
                                    WorkCaptionCommentItemBinding mcVar16 = this.f19485b;
                                    if (mcVar16 != null) {
                                        ImageView imageView = mcVar16.f21964h;
                                        MutabilityOwnership.m3746l(imageView, "binding.profileImageView");
                                        pixivImageLoader.m60f(context, str, imageView);
                                        WorkCaptionCommentItemBinding mcVar17 = this.f19485b;
                                        if (mcVar17 != null) {
                                            mcVar17.f21963g.setOnClickListener(new View$OnClickListenerC0151s(pixivWork, 20));
                                        } else {
                                            MutabilityOwnership.m3737u("binding");
                                            throw null;
                                        }
                                    } else {
                                        MutabilityOwnership.m3737u("binding");
                                        throw null;
                                    }
                                } else {
                                    MutabilityOwnership.m3737u("binding");
                                    throw null;
                                }
                            } else {
                                MutabilityOwnership.m3737u("nestedCommentAdapter");
                                throw null;
                            }
                        } else {
                            MutabilityOwnership.m3737u("nestedCommentAdapter");
                            throw null;
                        }
                    } else {
                        MutabilityOwnership.m3737u("nestedCommentAdapter");
                        throw null;
                    }
                } else {
                    MutabilityOwnership.m3737u("binding");
                    throw null;
                }
            } else {
                MutabilityOwnership.m3737u("binding");
                throw null;
            }
        }
    }

    @Override // p404oo.AbstractC5475a
    public Koin getKoin() {
        return AbstractC5475a.C5476a.m3211a(this);
    }
}
